﻿using System;
using NBuild.Fx;
using NBuild.Fx.Interfaces;
using NBuild.Tasks;

namespace NBuild.SampleProject
{
    [Build(DefaultTarget = "Test")]
    public sealed class BuildFile : BuildScript
    {
        public BuildFile(IBuildEngine engine) :
            base(engine)
        {
        }

        [Target(Name = "Test", DependsOn = "Test2", Description = "Just a test target")]
        public void Test1()
        {
            var tasks = GetTask<FileSystemTasks>();
            tasks.DisplayFiles(Files);
            Log(LogType.Normal, "Normal");
            Log(LogType.Detail, Config);
            Log(LogType.Info, "Hello World");
            Log(LogType.Warning, System.Data.LoadOption.Upsert);
            Log(LogType.Error, BuildEnvironment.BinName);
        }

        public void Test2()
        {
            Log(LogType.Detail, "In Test2");
        }

        private string _test;
        private TimeSpan _timeSpan;
        private Configuration _config;

        public string Test
        {
            get { return _test; }
            set { _test = value; }
        }

        public TimeSpan TimeSpan
        {
            get { return _timeSpan; }
            set { _timeSpan = value; }
        }

        public Configuration Config
        {
            get { return _config; }
            set { _config = value; }
        }

        public FileTaskItems Files
        {
            get
            {
                var files = new FileTaskItems();
                files.IncludeFiles(@"G:\Temp", "*.url", false);
                return files;
            }
        }
    }

    public enum Configuration
    {
        Debug,
        Release
    }
}
